package me.riverslob

import org.scalatest.{GivenWhenThen, FunSpec}
import scala.collection.mutable

/**
 * @author 郑治明(zm.zheng)
 * @version 2.1 , Created on  13-5-20 上午10:52
 */
class StackAccept extends FunSpec with GivenWhenThen{
  describe("A Stack"){
    it("should pop values in last-in-first-out-order"){
      given("a non-empty stack")
      val stack=new mutable.Stack[Int]
      stack.push(1)
      stack.push(2)
      val oldSize=stack.size

      when("when pop is invoked on the stack")
      val result=stack.pop()

      then("the most recently pushed element should be returned")
      assert(result === 2)

      and("the stack should have one less item than before")
      assert(stack.size === oldSize - 1)
    }
  }
}
